package com.baizhi.service.impl;

import com.baizhi.dao.EmployeeDao;
import com.baizhi.entity.Employee;
import com.baizhi.service.EmployeeService;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@Transactional
public class EmployeeServiceImpl implements EmployeeService {
    @Autowired
    private EmployeeDao employeeDao;

    @Override
    public void insert(Employee employee) {
        employeeDao.insert(employee);
    }

    @Override
    public void delete(Integer emsId) {
        employeeDao.delete(emsId);
    }

    @Override
    public void deleteAny(Integer[] emsIds) {
        employeeDao.deleteAny(emsIds);
    }

    @Override
    public void update(Employee employee) {
        employeeDao.update(employee);
    }

    @Override
    @Transactional(readOnly = true)
    public Employee selectById(Integer emsId) {
        return employeeDao.selectById(emsId);
    }

    @Override
    @Transactional(readOnly = true)
    public PageInfo<Employee> select(Integer page, Integer limit, String emsName, Integer deptId, Integer comId) {
        PageHelper.startPage(page,limit);
        PageInfo<Employee> pageInfo = new PageInfo<>(employeeDao.select(emsName,deptId,comId));
        return pageInfo;
    }
}
